package ru.papergames.battleserver.network.serverpackets.webserver;

import org.apache.log4j.Logger;
import org.mmocore.network.SendablePacket;
import ru.papergames.Config;
import ru.papergames.battleserver.network.WebServerClient;

/**
 * @author: atroshanin
 * Date: 18.04.2010
 * Time: 17:07:23
 */
public abstract class WebServerServerPacket extends SendablePacket<WebServerClient> implements WebServerServerPacketTypes {
    private static final Logger _log = Logger.getLogger(WebServerServerPacket.class.getName());

    /**
     * @see org.mmocore.network.SendablePacket#write()
     */
    @Override
    protected void write() {
        try {
            writePacketId();
            //_log.info(this.getType());
            writePacketData();
        }
        catch (Exception e) {
            _log.fatal("Client: " + getClient().toString() + " - Failed writing: " + getType() + " - L2J Server Version: " + Config.SERVER_VERSION + " - DP Revision: " + Config.DATAPACK_VERSION);
            e.printStackTrace();
        }
    }

    public void runImpl() {

    }

    protected abstract void writePacketId();

    protected abstract void writePacketData();

    /**
     * @return A String with this packet name for debuging purposes
     */
    public abstract String getType();
}
